package com.xiu.travel.config;

import com.aliyun.com.viapi.FileUtils;
import com.aliyuncs.exceptions.ClientException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lijie
 * @date 2023/7/6 20:16
 * @description AliFaceBodyConfig
 */
@Configuration
public class AliFaceBodyConfig
{
    @Value("${aliyun.accessKeyId}")
    public String ALIYUN_ACCESSKEYID;

    @Value("${aliyun.accessKeySecret}")
    public String ALIYUN_ACCESSKEYSECRET;
    /**
     * 使用AK&SK初始化账号Client
     *
     * @return Client
     * @throws Exception
     */
    public com.aliyun.facebody20191230.Client createClient() throws
            Exception
    {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 必填，您的 AccessKey ID
                .setAccessKeyId(ALIYUN_ACCESSKEYID)
                // 必填，您的 AccessKey Secret
                .setAccessKeySecret(ALIYUN_ACCESSKEYSECRET);
        // 访问的域名
        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new com.aliyun.facebody20191230.Client(config);
    }

    @Bean
    public FileUtils fileUtils() throws ClientException
    {
        return FileUtils.getInstance(ALIYUN_ACCESSKEYID, ALIYUN_ACCESSKEYSECRET);
    }
}
